package com.briup.hdfs;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * TODO
 *
 * @author 最美如初
 * @version 1.0
 * @date 2021/7/19
 * @description
 */
public class Student implements Writable {
    private long id;
    private String name;
    private int age;

    public Student() {
    }

    public Student(long id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void write(DataOutput out) throws IOException {
        out.writeLong(id);
        out.writeUTF(name);
        out.writeInt(age);
    }

    public void readFields(DataInput in) throws IOException {
        id=in.readLong();
        name=in.readUTF();
        age=in.readInt();
    }
}
